package com.sj.pojo;

import java.nio.Buffer;
import java.nio.ByteBuffer;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2022-07-14
 * Time: 上午 10:59
 * Description: 第一次协议
 *
 * @author xiaoqi
 * @since 2022-07-14
 */
public class FirstProtocol extends Protocol {

    public FirstProtocol(){

    }

    @Override
    public Protocol getProtocol(MsgTypeEnum msgType, String msg) {
        Protocol protocol = new FirstProtocol();
        Header header = new Header();
        header.setMsgType(msgType.getCode());
        header.setMsgLen(msg.getBytes().length);
        protocol.setHeader(header);
        protocol.setContent(msg);
        return protocol;
    }

    @Override
    public Protocol getProtocol(byte msgType, String msg) {
        Protocol protocol = new FirstProtocol();
        Header header = new Header();
        header.setMsgType(msgType);
        header.setMsgLen(msg.getBytes().length);
        protocol.setHeader(header);
        protocol.setContent(msg);
        return protocol;
    }
}